home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Science / µSim 1.0b5 folder / source / Scroll.c < prev    next >
Encoding:
Text File  |  1994-09-01  |  1.5 KB  |  63 lines  |  [TEXT/MMCC]

  1. /*
  2. Copyright © 1993,1994 by Fabrizio Oddone
  3. ••• ••• ••• ••• ••• ••• ••• ••• ••• •••
  4. This source code is distributed as freeware: you can copy, exchange, modify this
  5. code as you wish. You may include this code in any kind of application: freeware,
  6. shareware, or commercial, provided that full credits are given.
  7. You may not sell or distribute this code for profit.
  8. */
  9.  
  10. //#pragma load "MacDump"
  11.  
  12. #include    "UtilsSys7.h"
  13. #include    "Scroll.h"
  14.  
  15. #if defined(FabSystem7orlater)
  16.  
  17. //#pragma segment Main
  18.  
  19. /* VScrollRect: ultra-fast vertical ScrollRect which does not fill
  20. with the background pattern; useful when drawing in srcCopy */
  21.  
  22. void VScrollRect(RectPtr r, short dv)
  23. {
  24. GrafPtr    port;
  25. Rect    src,dst;
  26. register short    left,top,right,bottom;
  27.  
  28. if (dv != 0) {
  29.     GetPort(&port);
  30.     left    = (*port->visRgn)->rgnBBox.left;
  31.     top        = (*port->visRgn)->rgnBBox.top;
  32.     right    = (*port->visRgn)->rgnBBox.right;
  33.     bottom    = (*port->visRgn)->rgnBBox.bottom;
  34.     if (r->left < left)        r->left = left;
  35.     if (r->top < top)        r->top = top;
  36.     if (r->right > right)    r->right = right;
  37.     if (r->bottom > bottom)    r->bottom = bottom;
  38.     
  39.     if (dv > 0) {
  40.         topLeft(src) = topLeft(*r);
  41.         src.right    = r->right;
  42.         src.bottom    = r->bottom - dv;
  43.         
  44.         dst.left    = r->left;
  45.         dst.top        = r->top + dv;
  46.         botRight(dst) = botRight(*r);
  47.         }
  48.     else {
  49.         src.left    = r->left;
  50.         src.top        = r->top - dv;
  51.         botRight(src) = botRight(*r);
  52.         
  53.         topLeft(dst) = topLeft(*r);
  54.         dst.right    = r->right;
  55.         dst.bottom    = r->bottom + dv;
  56.         }
  57.     CopyBits(&port->portBits, &port->portBits, &src, &dst, srcCopy, (RgnHandle)nil);
  58.     }
  59. }
  60.  
  61. #endif
  62.  
  63.